package com.cet.programmercarl.algorithmperformancanalysis.哈希表;

/**
 * @program: algorithm
 * @description: 有效的字母异位词
 * @author: 陈恩涛
 * @create: 2022-03-12 20:39
 **/
public class LC242 {

    public static boolean isAnagram(String s, String t) {
        int[] alphabetCounter = new int[26];
        for (int i = 0; i < s.length(); i++) {
            alphabetCounter[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            alphabetCounter[t.charAt(i) - 'a']--;
        }
        for (int i : alphabetCounter) {
            if (i != 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {

    }
}
